package com.party.core.dao.read.mall;

import com.party.common.paging.Page;
import com.party.core.dao.read.BaseReadDao;
import com.party.core.model.mall.MallOrderDetail;
import com.party.core.model.mall.MallOrderOutputParent;
import com.party.core.model.mall.MallOrderOutputPay;
import com.party.core.model.mall.MallOrderWithLogisticsOutput;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @Author: Administrator.
 * @Description: 商城订单详情
 * @Date:Created in 2017/8/30 0030 上午 9:47.
 */
@Repository
public interface MallOrderDetailReadDao extends BaseReadDao<MallOrderDetail> {

    Long getSalesNum(@Param("productId") String productId, @Param(value = "goodsId") String goodsId, @Param("status") Set<Integer> status,
                     @Param(value = "productIds") List<String> productIds);

    List<MallOrderOutputParent> listWithLogistics(@Param(value = "orderId") String orderId,
                                                  @Param(value = "status") Set<Integer> status);

    /**
     * 获取已发货的商品及物流信息
     *
     * @param targetId 支付订单id
     * @return
     */
    List<MallOrderWithLogisticsOutput> listWithShipment(String targetId);

    /**
     * 获取待发货的商品
     *
     * @param orderId 主订单id
     * @return
     */
    List<MallOrderOutputParent> listWithNotShipment(@Param(value = "orderId") String orderId);

    /**
     * admin订单列表
     *
     * @param orderDetail
     * @param params
     * @param page
     * @return
     */
    List<MallOrderOutputPay> webListPage(@Param(value = "detail") MallOrderDetail orderDetail, @Param(value = "params") Map<String, Object> params, Page page);

    Long getNotRefund(@Param(value = "parentId") String parentId, @Param(value = "status") Integer status, @Param(value = "orderId") String orderId);

    /**
     * mobile订单列表
     *
     * @param orderDetail
     * @param params
     * @param page
     * @return
     */
    List<MallOrderOutputPay> payOrderList(@Param("detail") MallOrderDetail orderDetail, @Param("params") Map<String, Object> params, Page page);

    /**
     * 根据支付订单id获取订单信息
     *
     * @param orderId
     * @return
     */
    MallOrderDetail getUniqueByOrderId(@Param(value = "orderId") String orderId);

    /**
     * 根据支付订单获取主订单
     *
     * @param orderId 支付订单id
     * @return
     */
    List<MallOrderDetail> findParentByOrderId(@Param(value = "orderId") String orderId);

    /**
     * 我的分销订单
     *
     * @param orderDetail
     * @param params
     * @param page
     * @return
     */
    List<MallOrderOutputPay> getDistributorOrderList(@Param(value = "detail") MallOrderDetail orderDetail,
                                                     @Param(value = "params") Map<String, Object> params, Page page);

    /**
     * 我的收入数据
     *
     * @param params
     * @return
     */
    List<Map<String, Object>> getRevenueData(@Param(value = "params") Map<String, Object> params);

    Map<String, Object> findDataCountByDistributor(@Param("distributorId") String distributorId, @Param("createDate") Date createDate);

    Set<Integer> findStatusByOrderId(String orderId);

    Map<String, Object> countAnalyzeByDate(@Param("startDate") String startDate, @Param("endDate") String endDate);

    /**
     * 获取已结算金额
     *
     * @param memberId 用户id
     * @return 金额
     */
    Double getSumTotal(@Param("memberId") String memberId);
}
